const Sequelize = require('sequelize');
module.exports = function (sequelize, DataTypes) {
    return sequelize.define(
        't_dict_type',
        {
            id: {
                autoIncrement: true,
                type: DataTypes.BIGINT,
                allowNull: false,
                primaryKey: true,
                comment: '字典类型ID',
            },
            dict_code: {
                type: DataTypes.STRING(50),
                allowNull: false,
                comment: '字典编码',
                unique: 'dict_code',
            },
            dict_name: {
                type: DataTypes.STRING(100),
                allowNull: false,
                comment: '字典名称',
            },
            create_time: {
                type: DataTypes.DATE,
                allowNull: false,
                defaultValue: Sequelize.Sequelize.literal('CURRENT_TIMESTAMP'),
            },
            update_time: {
                type: DataTypes.DATE,
                allowNull: false,
                defaultValue: Sequelize.Sequelize.literal('CURRENT_TIMESTAMP'),
            },
        },
        {
            sequelize,
            tableName: 't_dict_type',
            timestamps: false,
            indexes: [
                {
                    name: 'PRIMARY',
                    unique: true,
                    using: 'BTREE',
                    fields: [{ name: 'id' }],
                },
                {
                    name: 'dict_code',
                    unique: true,
                    using: 'BTREE',
                    fields: [{ name: 'dict_code' }],
                },
            ],
        },
    );
};
